package com.gpy.hospital.cms.controller;

import com.github.pagehelper.PageInfo;
import com.gpy.hospital.cms.pojo.LiuYan;
import com.gpy.hospital.cms.service.ILiuYanService;
import com.gpy.hospital.common.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author
 * @Date 2020/3/1 22:04
 * @Desc
 **/
@Controller
public class LiuYanController {
    @Autowired
    private ILiuYanService liuYanService;

    @GetMapping("/cms/liuyan/page")
    public String liuyanPage(){
        return "/cms/liuyanList";
    }


    @GetMapping("/cms/liuyan/list")
    @ResponseBody
    public ServerResponse keShiList(
            @RequestParam(value = "page", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "limit", defaultValue = "10") Integer pageSize,
            @RequestParam(value = "name", required = false) String name){
        PageInfo<LiuYan> pageInfo = liuYanService.get(pageNum, pageSize, name);
        return ServerResponse.createBySuccess("查询成功！", pageInfo.getList(), pageInfo.getTotal());
    }

    @GetMapping("/cms/liu/yan/hui/fu")
    public String huiFuLiuYan(@RequestParam("liuYanId") Integer liuYanId, Model model) {
        LiuYan liuYan = liuYanService.getById(liuYanId);
        model.addAttribute("liuYan", liuYan);
        return "/cms/huiFuLiuYan";
    }



}
